# -*- python -*-
# ex: set syntax=python:
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# See master.experimental/slaves.cfg for documentation.

def mac():
  cq_slaves = (
      ['vm%d-m4' % i for i in ([213, 256, 257, 258, 902, 903, 1000,
                                1068] +
                               range(277, 300) + range(552, 555) +
                               range(682, 711) + range(860, 870) +
                               range(969, 987)) + range(783, 788) +
                               range(1085, 1104)
                               ])

  cq_builders = [
      'mac_chromium_compile_dbg_ng',
      'mac_chromium_rel_ng',
  ]

  optional0_slaves = ['vm%d-m4' % i for i in [713, 645, 646, 647, 648]]
  optional0_builders = [
      'mac_chromium_dbg_ng',
      'mac_chromium_gn_upload',
      'mac_upload_clang',
      'mac_optional_gpu_tests_rel',
  ]

  optional1_slaves = ['vm723-m4']
  optional1_builders = [
      'mac_nacl_sdk',
      'mac_nacl_sdk_build',
  ]

  optional2_slaves = ['vm1025-m4']
  optional2_builders = [
      'mac_chromium_compile_rel_ng',
  ]

  # When adding builders here, make sure there is a maximum of 3 different
  # values for slavebuilddir. Otherwise we'll run out of disk space.
  optional3_slaves = ['build190-m4', 'vm1026-m4']
  optional3_builders =  [
      'mac_chromium_archive_rel_ng',
  ]

  # Highend physical mac pro running OSX 10.10.
  optional3_slaves_highend = ['build554-m4']
  optional3_builders_highend = [
      'mac_chromium_variable_10.10',
      'mac_chromium_variable_10.10_layout',
  ]

  optional4_slaves = ['build9-m4']
  optional4_builders = [
      'mac_chromium_variable_10.12',
  ]

  # Highend physical mac pro running OSX Mac 10.11.
  optional4_slaves_highend = ['build555-m4']
  optional4_builders_highend = [
      'mac_chromium_variable_10.11',
      'mac_chromium_variable_10.11_layout',
  ]

  # Highend physical mac pros running OSX 10.9.
  optional5_slaves_highend = ['build556-m4', 'build557-m4']
  optional5_builders_highend = [
      'mac_chromium_asan_variable',
      'mac_chromium_variable',
      'mac_chromium_variable_archive',
      'mac_chromium_variable_chrome',
      'mac_chromium_variable_layout',
  ]

  # Highend physical mac pros running OSX 10.9 for Findit flake analysis.
  optional6_slaves_highend = ['build48-m4']
  optional6_builders_highend = [
      'mac_chromium_variable_deflake',
  ]

  optional7_slaves = ['vm117-m4', 'vm804-m4']
  optional7_builders =  [
      'mac_chromium_asan_rel_ng',
  ]

  out = []
  out.extend(
    {
      'master': 'TryServerChromiumMac',
      'builder': cq_builders,
      'preferred_builder': cq_builders[i % len(cq_builders)],
      'hostname': slave,
      'os': 'mac',
      'version': '10.9',
      'bits': '64',
      'pool': 'mac_cq',
    } for i, slave in enumerate(cq_slaves)
  )
  out.extend(
    {
      'master': 'TryServerChromiumMac',
      'builder': optional0_builders,
      'hostname': slave,
      'os': 'mac',
      'version': '10.9',
      'bits': '64',
      'pool': 'mac_optional0_dbg',
    } for slave in optional0_slaves
  )
  out.extend(
    {
      'master': 'TryServerChromiumMac',
      'builder': optional1_builders,
      'hostname': slave,
      'os': 'mac',
      'version': '10.9',
      'bits': '64',
      'pool': 'mac_optional1_dbg',
    } for slave in optional1_slaves
  )
  out.extend(
    {
      'master': 'TryServerChromiumMac',
      'builder': optional2_builders,
      'hostname': slave,
      'os': 'mac',
      'version': '10.9',
      'bits': '64',
      'pool': 'mac_optional_rel',
    } for slave in optional2_slaves
  )
  out.extend(
    {
      'master': 'TryServerChromiumMac',
      'builder': ['mac_chromium_10.10_rel_ng'],
      'hostname': slave,
      'os': 'mac',
      'version': '10.10',
      'bits': '64',
      'pool': 'mac_10_10',
    } for slave in ['build%d-m4' % i for i in xrange(158, 167)] +
                   ['build%d-m4' % i for i in xrange(179, 189)]
  )
  out.extend(
    {
      'master': 'TryServerChromiumMac',
      'builder': ['mac_chromium_10.12_rel_ng'],
      'hostname': slave,
      'os': 'mac',
      'version': '10.12',
      'bits': '64',
      'pool': 'mac_10_12',
    } for slave in ['vm1365-m4']
  )
  out.extend(
    {
      'master': 'TryServerChromiumMac',
      'builder': ['mac_chromium_10.10_macviews'],
      'hostname': slave,
      'os': 'mac',
      'version': '10.10',
      'bits': '64',
      'pool': 'macviews',
    } for slave in ['build416-m4']
  )
  out.extend(
    {
      'master': 'TryServerChromiumMac',
      'builder': optional3_builders,
      'hostname': slave,
      'os': 'mac',
      'version': '10.12',
      'bits': '64',
      'pool': 'mac_optional_10_12',
    } for slave in optional3_slaves
  )
  out.extend(
    {
      'master': 'TryServerChromiumMac',
      'builder': optional3_builders_highend,
      'hostname': slave,
      'os': 'mac',
      'version': '10.10',
      'bits': '64',
      'pool': 'mac_optional_10_10_highend',
    } for slave in optional3_slaves_highend
  )
  out.extend(
    {
      'master': 'TryServerChromiumMac',
      'builder': optional4_builders,
      'hostname': slave,
      'os': 'mac',
      'version': '10.12',
      'bits': '64',
      'pool': 'mac_optional_10_12',
    } for slave in optional4_slaves
  )
  out.extend(
    {
      'master': 'TryServerChromiumMac',
      'builder': optional4_builders_highend,
      'hostname': slave,
      'os': 'mac',
      'version': '10.11',
      'bits': '64',
      'pool': 'mac_optional_10_11_highend',
    } for slave in optional4_slaves_highend
  )
  out.extend(
    {
      'master': 'TryServerChromiumMac',
      'builder': optional5_builders_highend,
      'hostname': slave,
      'os': 'mac',
      'version': '10.9',
      'bits': '64',
      'pool': 'mac_optional_10_9_highend',
    } for slave in optional5_slaves_highend
  )
  out.extend(
    {
      'master': 'TryServerChromiumMac',
      'builder': optional6_builders_highend,
      'hostname': slave,
      'os': 'mac',
      'version': '10.9',
      'bits': '64',
      'pool': 'mac_optional_10_9_highend_2',
    } for slave in optional6_slaves_highend
  )
  out.extend(
    {
      'master': 'TryServerChromiumMac',
      'builder': optional7_builders,
      'hostname': slave,
      'os': 'mac',
      'version': '10.12',
      'bits': '64',
      'pool': 'mac_optional_10_12_2',
    } for slave in optional7_slaves
  )

  return out


def ios():
  slave_map = {
    'ios-device': [
      'build456-m4',
      'build457-m4',
      'build458-m4',
      'build459-m4',
      'build460-m4',
      'build461-m4',
      'build462-m4',
      'build463-m4',
      'build464-m4',
      'build465-m4',
    ],
    'ios-device-xcode-clang': [
      'build496-m4',
      'build497-m4',
      'build540-m4',
      'build541-m4',
      'build542-m4',
      'vm190-m4',
      'vm788-m4',
      'vm795-m4',
      'vm796-m4',
      'vm797-m4',
    ],
    'ios-simulator': [
      'build73-m4',
      'vm671-m4',
      'vm672-m4',
      'vm673-m4',
      'vm674-m4',
      'vm675-m4',
      'vm676-m4',
      'vm677-m4',
      'vm679-m4',
      'vm800-m4',
      'vm806-m4',
      'vm807-m4',
      'vm808-m4',
      'vm809-m4',
      'vm810-m4',
      'vm811-m4',
      'vm812-m4',
      'vm813-m4',
      'vm814-m4',
      'vm815-m4',
      'vm816-m4',
      'vm817-m4',
      'vm821-m4',
      'vm822-m4',
      'vm823-m4',
      'vm825-m4',
      'vm826-m4',
      'vm827-m4',
      'vm828-m4',
      'vm897-m4',
      'vm898-m4',
      'vm899-m4',
      'vm900-m4',
      'vm901-m4',
      'vm1069-m4',
      'vm1070-m4',
      'vm1071-m4',
      'vm1072-m4',
      'vm1073-m4',
      'vm1074-m4',
      'vm1075-m4',
      'vm1076-m4',
      'vm1077-m4',
      'vm1078-m4',
      'vm1079-m4',
      'vm1080-m4',
      'vm1203-m4',
      'vm1204-m4',
      'vm1205-m4',
      'vm1206-m4',
      'vm1207-m4',
      'vm1208-m4',
    ],
    'ios-simulator-cronet': [
      'vm255-m4',
      'vm667-m4',
    ],
    'ios-simulator-eg': [
      'build21-m4',
      'build22-m4',
      'build23-m4',
      'build24-m4',
      'build25-m4',
      'build50-m4',
      'build51-m4',
      'build52-m4',
      'build53-m4',
      'vm608-m4',
    ],
    'ios-simulator-xcode-clang': [
      'build418-m4',
      'build419-m4',
      'build420-m4',
      'build421-m4',
      'build422-m4',
      'build423-m4',
      'build424-m4',
      'build425-m4',
      'vm711-m4',
      'vm712-m4',
      'vm1104-m4',
      'vm1105-m4',
    ],
  }

  slaves = []

  for builder in sorted(slave_map):
    slaves.extend([{
      'master': 'TryServerChromiumMac',
      'builder': builder,
      'hostname': slave,
      'os': 'mac',
      'version': '10.11',
    } for slave in slave_map[builder]])

  return slaves


slaves = mac() + ios()
